/*
 * Member.h
 *
 *  Created on: 2014. 7. 17.
 *      Author: mega
 */

#ifndef GUILDSERVER_MEMBER_H_
#define GUILDSERVER_MEMBER_H_

#include <stdint.h>
#include <time.h>
#include <string>

namespace GuildServer {

class Member
{
public:
	struct MemberInfo
	{
		uint64_t	_socialID;
		uint32_t	_guildSeq;	// 가입한 길드 SEQ
		uint16_t	_level;		// 길드원 레벨
		uint16_t	_serverid;	// 접속 서버

		time_t		_regDate;	// 길드 가입 시간
		time_t		_loginTime;	// 로그인 시간

		int32_t		_contributeScore;	// 누적 기여 점수
		int32_t		_dailyScore;		// 일일 기여 점수
		time_t		_dailyInitTime;		// 일일 기여 점수 초기화 시간

		std::string	_profileURL;
		std::string	_nickname;

		void Clear()
		{
			_guildSeq			= 0;
			_regDate			= 0;
			_loginTime			= 0;
			_contributeScore	= 0;
			_level				= 0;
			_serverid			= 0;
			_socialID			= 0;
			_dailyScore			= 0;
			_dailyInitTime		= 0;
			_profileURL.clear();
			_nickname.clear();
		}

		MemberInfo()
		{
			Clear();
		}
	};

public:
	Member();
	virtual ~Member();

	void	Initialize(uint32_t userSeq);
	void	Finalize();

	void	Open(MemberInfo & info);

	uint32_t		GetSeq() { return m_UserSeq; }
	MemberInfo &	GetData() { return m_MemberInfo; }


	uint16_t GetServer() { return m_MemberInfo._serverid; }
	void SetServer( uint16_t server_id ) { m_MemberInfo._serverid = server_id; }

	void	FlushMemberPoint();
	void	FlushLoginTime();

	void	SetMemberFlushDB(bool bFlushDB) { m_bFlushDB = bFlushDB; }
	bool	GetMemberFlushDB() { return m_bFlushDB; }

	void	ChangeMemberScore(int score, int dailyMaxScore);

	void	SetNickname( std::string a_nickname, int a_iLevel ) { m_MemberInfo._nickname = a_nickname.c_str(); m_MemberInfo._level = a_iLevel; }

private:
	uint32_t	m_UserSeq;
	bool		m_bFlushDB;
	MemberInfo	m_MemberInfo;
};

} /*GuildServer*/



#endif /* GUILDSERVER_MEMBER_H_ */
